// run: $exec < input
#include <iostream>

int const maxn = 700;
bool map[maxn][maxn];
int f[maxn][maxn];
int left[maxn][maxn];
int up[maxn][maxn];
int n, m;

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin >> n >> m;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			char ch; std::cin >> ch;
			map[i][j] = ch == '.';
		}

	for (int j = 1; j <= m; j++)
		for (int i = 1; i <= n; i++)
			left[i][j] = left[i - 1][j] + (map[i][j] && map[i][j - 1]);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			up[i][j] = up[i][j - 1] + (map[i][j] && map[i - 1][j]);
			f[i][j] = f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1];
			if (map[i][j] && map[i][j - 1]) f[i][j]++;
			if (map[i][j] && map[i - 1][j]) f[i][j]++;
		}
	int q; std::cin >> q;
	for (int i = 0; i < q; i++) {
		int x1, y1, x2, y2;
		std::cin >> x1 >> y1 >> x2 >> y2;
		int ans =  f[x2][y2] - f[x2][y1 - 1] - f[x1 - 1][y2] + f[x1 - 1][y1 - 1];
		ans -= left[x2][y1] - left[x1 - 1][y1];
		ans -= up[x1][y2] - up[x1][y1 - 1];
		std::cout << ans << "\n";
//		std::cout << left[x2][y1] - left[x1 - 1][y1] << "\n"; std::cout << up[x1][y2] - up[x1][y2 - 1] << "\n";
//		std::cout << f[x2][y2] << " " << f[x2][y1 - 1] << " " <<  f[x1 - 1][y2] << " " <<  f[x1 - 1][y1 - 1] << "\n";
	}
}

